package regex;

import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Demo4 {
    public static void main(String[] args) {

        String regex1 = "\\d";
        String string = "aaad3dfsa1dfgda8sdaf0";
        Pattern pattern = Pattern.compile(regex1);
        Matcher matcher = pattern.matcher(string);
        boolean findFlag = false;
        while (matcher.find()) {
            System.out.println("find success :"+ matcher.start() + "~" + matcher.end());
            findFlag = true;
        }
        if (!findFlag) {
            System.out.println("find fail");
        }
        String[] strArray = string.split(regex1);
        System.out.println(Arrays.toString(strArray));
        for (String item : strArray) {
            System.out.println(item);
        }


    }

}
